package com.wyzz.hr.pojo;

import java.util.Map;

import com.wyzz.hr.base.ComonBeans;
import com.wyzz.hr.pojo.base.BaseOutmatch;

public class Outmatch extends BaseOutmatch {

	public Outmatch() {
	}

	public Outmatch(String omId) {
		super(omId);
	}

	public Outmatch(String omId, OutmatchBasic omOmb, OutmatchModel omOmm,
			String omFieldDesc, Integer omSortId, Integer omColumnWidth,
			Integer omIsGroup) {
		super(omId, omOmb, omOmm, omFieldDesc, omSortId, omColumnWidth,
				omIsGroup);
	}

	public void initByOutmatchBasic(OutmatchBasic outmatchBasic) {
		super.setOmOmb(outmatchBasic);
		super.setOmFieldDesc(outmatchBasic.getOmbFieldDesc());
		super.setOmFormat(outmatchBasic.getOmbFormat());
		super.setOmColumnWidth(outmatchBasic.getOmbColumnWidth());
		super.setOmSortId(outmatchBasic.getOmbSortId());
		super.setOmIsGroup(Integer.valueOf(0));
		setOmIsOutput(Integer.valueOf(0));
	}

	public void setAllMaps() {
		formatDesc = null;
		omStatisticMap = null;
		omIsGroupMap = null;
		if (getOmOmb() == null || getOmOmb().getOmbDataType() == null
				|| getOmOmb().getOmbCanGroup() == null)
			return;
		omIsGroupMap = ComonBeans.getValuesToMap(PROP_OM_IS_GROUP,
				new boolean[0]);
		if (getOmOmb().getOmbCanGroup().intValue() != 1) {
			omIsGroupMap.remove("1");
			omIsGroupMap.remove("2");
		}
		String ombDataType = getOmOmb().getOmbDataType();
		String methods[] = null;
		if (ombDataType.compareTo("date") == 0)
			methods = (new String[] { "count", "max", "min", "mode" });
		else if (ombDataType.compareTo("integer") == 0)
			methods = (new String[] { "avg", "sum", "count", "max", "min",
					"mode" });
		else if (ombDataType.compareTo("decimal") == 0)
			methods = (new String[] { "max", "min", "avg", "sum", "mode",
					"count" });
		else if (ombDataType.compareTo("string") == 0)
			methods = (new String[] { "count", "max", "min", "mode" });
		else
			methods = (new String[] { "count", "max", "min", "mode" });
		if (methods != null)
			omStatisticMap = ComonBeans.getValuesToMap(PROP_OM_STATISTIC,
					methods, new boolean[] { true });
		formatDesc = ComonBeans.getParameterValue(
				OutmatchBasic.PROP_OMB_FORMAT, new String[] { ombDataType });
	}

	public String getFormatDesc() {
		return formatDesc;
	}

	public Map getOmIsGroupMap() {
		return omIsGroupMap;
	}

	public Map getOmStatisticMap() {
		return omStatisticMap;
	}

	public Integer getOmIsOutput() {
		return omIsOutput;
	}

	public void setOmIsOutput(Integer omIsOutput) {
		this.omIsOutput = omIsOutput;
	}

	private static final long serialVersionUID = 1L;
	private Integer omIsOutput;
	private Map omIsGroupMap;
	private Map omStatisticMap;
	private String formatDesc;
}
